window.onload=function(){
    fetch('../../api/aside.json')
	.then(function(res){return res.json()})
	.then(function(data){
		// console.log(data)
		var one = document.querySelector('.aside .back')
		one.innerHTML=div(data)
	})
	function div(data){
		return data.map(function(item,index){
			return`
            <li>
            <a href="${item.url}" target="iframe">
                <img src="${item.img}" alt="">
                <p>${item.title}</p>
            </a>
        </li>
			`
		}
		).join('')
	}
}
//---设置按钮-------------------------------------------------
var btn = document.querySelector('.top .gn .gn1 img:nth-child(2)')
var btn1 = document.querySelector('.top .gn .gn1 img:nth-child(1)')
var ifra = document.querySelector('iframe')
var ul = document.querySelector('.top .gn .gn1 ul')
ul.style.display='none'
btn.addEventListener('mousedown',function(){
	btn.style.transform = 'scale(0.7)'
	if(ul.style.display=='none'){
		ul.style.display='block'
		
	}else{
		ul.style.display='none'
	}
})
btn.addEventListener('mouseup',function(){
	btn.style.transform = 'scale(1)'
})

btn1.addEventListener('click',function(){
	ifra.src='../../lib/hous/demo/new.html'
})
//--------------获取用户名---------------------------------------
var na = document.querySelector('.top .name p')
var loc = location.search
loc = loc.substr(1)
na.innerHTML='欢迎您！'+ loc
// ----------------退出系统-------------------------------------
var tui   =document.querySelector('.gn .gn1 ul li:nth-child(5)')
console.log(tui)
tui.addEventListener('click',function(){
	alert('确定要退出系统吗？')
	location.href='../../html/afterEnd/administration.html'
})